var UserData=require('UserData')
cc.Class({
    extends: cc.Component,

    properties: {
        RestaurantListNode:{
            default:null,
            type:cc.Node,
        }
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        //this.node.getChildByName('Label').getComponent(cc.Label) = this.node.getChildByName('Label').getComponent(cc.Label)
        this.node.getChildByName('Label').getComponent(cc.Label).string = 'x1'
        this.multiplyTimes = 1

    },
    changeTimes(target,times){
        if(this.multiplyTimes == 1){
            this.node.getChildByName('Label').getComponent(cc.Label).string = 'x10'
            this.multiplyTimes = 10
        }else if(this.multiplyTimes == 10){
            this.node.getChildByName('Label').getComponent(cc.Label).string = 'x50'
            this.multiplyTimes = 50
        }else if(this.multiplyTimes == 50){
            this.node.getChildByName('Label').getComponent(cc.Label).string = 'Max'
            this.multiplyTimes = -1
        }else if(this.multiplyTimes == -1){
            this.node.getChildByName('Label').getComponent(cc.Label).string = 'x1'
            this.multiplyTimes = 1
        }
        
        if(times){
            if(times!=-1){
                this.node.getChildByName('Label').getComponent(cc.Label).string = 'x'+times
            }else{
                this.node.getChildByName('Label').getComponent(cc.Label).string = 'Max'
            }
            this.multiplyTimes = times
        }
        for(let i=0;i<this.RestaurantListNode.children.length;i++){
            this.RestaurantListNode.children[i].getComponent('Restaurant').upgradeMultiplier = this.multiplyTimes
        }
        UserData.addCurrentMoney(0)
        UserData.runtimeState.multiplyTimes = this.multiplyTimes
    },

    // update (dt) {},
});
